/* 发布活动 */
import request from '@/utils/request';
import {object2Url} from "@/utils/trans";

// 活动发布
export async function issue(data) {
  const res = await request.post('/business/shopCode/code/issue', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


// 获取是否已进件
export async function incomingParts(data) {
  const res = await request.post('/business/MerchantManagement/page', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询中奖奖品
export async function queryPrizes(data) {
  const res = await request.post('/business/mobile/getWinningRecord', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询奖品
export async function listofprizes(data) {
  const res = await request.post('/business/listofprizes/page', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



// 查询'爆店码'活动列表
export async function getActivity(data) {
  const res = await request.post('/business/shopCode/code/shopList', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询活动列表 old
export async function getActivity2(data) {
  const res = await request.post('/business/shopCode/code/getActivity', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

export async function getActivityes(data) {
  const res = await request.post('/business/MerchantManagement/detailsExplosiveStoreCodes', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}




// 删除活动
export async function deleteActivity(data) {
  const res = await request.post('/business/shopCode/code/delete', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


// 提交脚本剪辑任务
export async function submitProjectJob(data) {
  const res = await request.post('/business/montage/project/submitMediaProducingJob', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 提交自定义剪辑任务
export async function submitDiyJob(data) {
  const res = await request.post('/business/montage/diy/submitDiyMediaProducingJob', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 提交图文剪辑任务
export async function submitImageJob(data) {
  const res = await request.post('/business/montage/image/submitImageMediaProducingJob', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}




export async function deleteActivity222222(ids) {
  let item=[]
  item.push(ids)
  console.log("ids1111111111",ids)
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    ts,
    ua,
    ids:item
  };
  let url = `/business/shopCode/code/delete${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
